I am back! (sorry) I tried to make a release build and run it to defeat the checked iterators and see the results,
1. clearly, the order is not correct in the associative vector (either mine or Loki's, they give similar results), std::map works as expected
2. profiling shows a huge difference between using a std::map and an sorted vector...
My program is for running scientific calculations, so I am annoyed with the performance issue...
I use a custom key like so:
Code:
inline bool
Link::Energy_Lookup_Key::operator<(const Link::Energy_Lookup_Key& rhs) const
{
return origin_species_ < rhs.origin_species_
|| site_name_ < rhs.site_name_
|| neighbor_species_ < rhs.neighbor_species_;
}
where I simply compare all of the data members using operator< could the problem be here? due to C++ shortcutting the || for example? Or I should better use &&? I am now thinking this could be the problem.
As a side note, if anyone is interested I just found a Dr. Dobb's article about "Maps with Extensive Keys" this is relevant to my problem so I give the link: http://www.ddj.com/cpp/184402065
EDIT: I'll answer my own question, yes operator|| was not correct, operator&& in the key gives correct results.
Code:
inline bool
Link::Energy_Lookup_Key::operator<(const Link::Energy_Lookup_Key& rhs) const
{
return origin_species_ < rhs.origin_species_
&& site_name_ < rhs.site_name_
&& neighbor_species_ < rhs.neighbor_species_;
}